package tech.aistar.day09.generics;

/**
 * 本类用来演示: 泛型方法
 *
 * @author: success
 * @date: 2022/7/29 2:04 下午
 */
public class DemoMethod {

    public <T> void find(T t){
        System.out.println("find:"+t);
    }

    public <T> T get(T t){
        System.out.println("find:"+t);
        return t;
    }

    public static <T> void find2(T t){
        System.out.println("find:"+t);
    }

    //如果没有泛型,只能设置成Object
    public Object add(Object obj){
        return obj;
    }
}
class DemoMethodTest{
    public static void main(String[] args) {
        DemoMethod m = new DemoMethod();
        //m.find(10);
        //
        //m.find("admin");

        String obj = m.get("java");
        System.out.println(obj);
        Integer x = m.get(100);
        System.out.println(x);

        String data = (String) m.add("tom");//强制类型转换
    }
}
